package com.ruiya.staging.goods.locate.client;

import com.ruiya.staging.goods.data.grpc.*;
import net.devh.boot.grpc.client.inject.GrpcClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class DataIOClient {
    private static final Logger _log = LoggerFactory.getLogger(DataIOClient.class);

    @GrpcClient("goods-data-io")
    private DataIOServiceGrpc.DataIOServiceBlockingStub dataIOStub;

    public LocateGoodsIdResponse locateGoodsId(LocateGoodsIdRequest request) {
        _log.info("locateGoodsId. tid={}, shardingKey={}", request.getUri().getTid(), request.getUri().getSharding());
        LocateGoodsIdResponse response = this.dataIOStub.locateGoodsId(request);
        _log.info("locateGoodsId. tid={}, code={}", request.getUri().getTid(), response.getStatus().getCode());
        return response;
    }

}
